<template>
	<view class="content">

		<u-notify ref="uNotify" message="Hi uView"></u-notify>

		<view class="inner">
			<!-- 顶部标题 -->
			<!-- <view class="top_title">预约信息填写</view> -->
			<!-- 中间内容 -->
			<view class="center">
				<view class="c_row">
					<text class="c_title">实验室编号：</text>
					<text class="c_content">{{baseInfo.laboratoryId}}</text>
				</view>
				<view class="c_row">
					<view class="c_title">实验室名称：<text style="font-weight: 400;">{{baseInfo.labName}}</text></view>

				</view>
				<view class="c_row">
					<view class="c_title">实验室地址：</view>
					<view class="c_content">{{baseInfo.address}}</view>
				</view>
				<view class="c_row">
					<text class="c_title">预约日期：</text>
					<text class="c_content">{{baseInfo.dateTime}}</text>
				</view>
				<view class="c_row">
					<u-row>
						<u-col :span="12">
							<text class="c_title">预约时间段：</text>
							<text class="c_content">{{baseInfo.start}}-{{baseInfo.end}}</text>

						</u-col>

					</u-row>
				</view>
				<view class="c_row">
					<view class="check_way">审核方式：
						<view class="check_type">

							<u-tag v-if="baseInfo.isExamine==1" text="人工审核" size="mini"></u-tag>
							<u-tag v-if="baseInfo.isExamine==0" text="自动审核" type="success" size="mini"></u-tag>
						</view>
					</view>
				</view>
				<view class="c_row">
					<view class="c_title">申请原因：</view>
					<view class="c_content">
						<u--textarea maxlength="200" count height="100" v-model="form.askReason"
							placeholder="请输入内容"></u--textarea>
					</view>
				</view>


			</view>

		</view>
		<!-- 底部按钮 -->
		<view class="bottom">
			<u-button type="primary" text="提交申请" @click="handleSubmit"></u-button>
		</view>

	</view>
</template>

<script>
	import {
		createRes
	} from '../../api/laboratory.js'
	export default {
		data() {
			return {
				show: true,
				baseInfo: {},
				form: {
					askReason: "",

				}
			};
		},
		onLoad(options) {
			let a = JSON.parse(decodeURIComponent(options.baseInfo))
			this.baseInfo = {
				...a
			}
			this.form.userId = a.userId
			this.form.dayTimeId = a.dayTimeId
			this.form.type = a.type
			this.form.isExamine = a.isExamine

		},
		methods: {
			handleSubmit() {



				if (!this.form.askReason) {
					uni.$u.toast('请输入申请原因')
				} else {
					createRes(this.form).then(res => {
						// console.log(res);
						if (this.form.isExamine == 0) {
							// this.$refs.uNotify.show({
							// 	type: 'success',
							// 	message: '预约成功',
							// 	duration: 1000 * 2,
							// })
							uni.$u.toast("预约成功！")
						} else {
							// this.$refs.uNotify.show({
							// 	type: 'success',
							// 	message: '申请成功',
							// 	duration: 1000 * 2,
							// })
							uni.$u.toast("申请成功")
						}

						setTimeout(() => {
							uni.navigateBack()
						}, 800)



					})
				}
				// console.log(this.form);
				// createRes(this.form)
			}
		}
	}
</script>

<style lang="scss">
	.content {
		width: 100%;
		min-height: 100vh;
		box-sizing: border-box;
		padding: 30upx;
		background-color: #fff;

		.inner {
			width: 100%;
			min-height: 70vh;
			background-color: #fff;
			box-shadow: 0 0 10px rgba(0, 0, 0, .15);
			border-radius: 20upx;
			overflow: hidden;

			.top_title {
				width: 100%;
				height: 80upx;
				font-size: 40upx;
				font-weight: 700;
				text-align: center;
				// border-bottom: 2px solid #ccc;
				line-height: 80upx;
			}

			.center {
				box-sizing: border-box;
				padding: 20upx;
				width: 100%;

				.c_row {
					width: 100%;
					margin-bottom: 30upx;

					.c_title {
						width: 100%;
						font-size: 35upx;
						font-weight: 700;
						text-align: left;
						margin-bottom: 10upx;
					}

					.c_content {
						width: 100%;
						font-size: 35upx;
						text-align: left;
					}

					.check_way {
						font-weight: 700;
						margin-bottom: 15upx;
						margin-top: 20upx;
						display: flex;
						flex-direction: row;
						justify-content: flex-start;
						align-items: center;
						font-size: 35upx;

						.check_type {
							width: 122upx;

						}
					}
				}



			}


		}

		.bottom {
			box-sizing: border-box;
			padding: 0 20upx;
			width: 100%;
			margin-top: 40upx;

		}
	}
</style>